import { prisma } from '../../../utils/prisma'
import { getUserIdOrThrow } from '../../../utils/guard'

export default eventHandler(async (event) => {
  const userId = getUserIdOrThrow(event)
  const templates = await prisma.rewardTemplate.findMany({
    where: { userId, isArchived: false },
    orderBy: { id: 'asc' }
  })
  return { templates }
})


